Вы сказали:
Привет! Ты можешь дополнить этот биндинг xcb до используемого состояния, а то и до полного? То, что уже есть успешно проходит тестирование: происходит подключение, отображение окна, реакция на сообщения. Можно оставить как есть по юнитам или объединить в один. unit xcb_bindings;
{$mode objfpc}{$H+}
{$PACKRECORDS C}
interface
uses
CTypes, BaseUnix;
const
libxcb = 'libxcb.so.1';
type
// Basic types
uint8_t = cuint8;
uint16_t = cuint16;
uint32_t = cuint32;
uint64_t = cuint64;
int = cint;
size_t = csize_t;
// Opaque structures
Pxcb_connection_t = ^xcb_connection_t;
xcb_connection_t = record end;
Pxcb_special_event_t = ^xcb_special_event_t;
xcb_special_event_t = record end;
Pxcb_extension_t = ^xcb_extension_t;
xcb_extension_t = record
name: PChar;
global_id: cint;
end;
// Generic structures
Pxcb_generic_iterator_t = ^xcb_generic_iterator_t;
xcb_generic_iterator_t = record
data: Pointer;
rem: cint;
index: cint;
end;
Pxcb_generic_reply_t = ^xcb_generic_reply_t;
xcb_generic_reply_t = record
response_type: uint8_t;
pad0: uint8_t;
sequence: uint16_t;
length: uint32_t;
end;
Pxcb_generic_event_t = ^xcb_generic_event_t;
xcb_generic_event_t = record
response_type: uint8_t;
pad0: uint8_t;
sequence: uint16_t;
pad: array[0..6] of uint32_t;
full_sequence: uint32_t;
end;
Pxcb_generic_error_t = ^xcb_generic_error_t;
xcb_generic_error_t = record
response_type: uint8_t;
error_code: uint8_t;
sequence: uint16_t;
resource_id: uint32_t;
minor_code: uint16_t;
major_code: uint8_t;
pad0: uint8_t;
pad: array[0..4] of uint32_t;
full_sequence: uint32_t;
end;
Pxcb_void_cookie_t = ^xcb_void_cookie_t;
xcb_void_cookie_t = record
sequence: cuint;
end;
// Auth structure
Pxcb_auth_info_t = ^xcb_auth_info_t;
xcb_auth_info_t = record
namelen: cint;
name: PChar;
datalen: cint;
data: PChar;
end;
// Setup structure
Pxcb_setup_t = ^xcb_setup_t;
xcb_setup_t = record
status: uint8_t;
pad0: uint8_t;
protocol_major_version: uint16_t;
protocol_minor_version: uint16_t;
length: uint16_t;
release_number: uint32_t;
resource_id_base: uint32_t;
resource_id_mask: uint32_t;
motion_buffer_size: uint32_t;
vendor_len: uint16_t;
maximum_request_length: uint16_t;
roots_len: uint16_t;
pixmap_formats_len: uint16_t;
image_byte_order: uint8_t;
bitmap_format_bit_order: uint8_t;
bitmap_format_scanline_unit: uint8_t;
bitmap_format_scanline_pad: uint8_t;
min_keycode: uint8_t;
max_keycode: uint8_t;
pad1: array[0..3] of uint8_t;
end;
// Pointer types for function parameters
PPxcb_generic_error_t = ^Pxcb_generic_error_t;
Puint32_t = ^uint32_t;
// Geometry functions
Pxcb_get_geometry_cookie_t = ^xcb_get_geometry_cookie_t;
xcb_get_geometry_cookie_t = record
sequence: cuint;
end;
Pxcb_get_geometry_reply_t = ^xcb_get_geometry_reply_t;
xcb_get_geometry_reply_t = record
response_type: cuint8;
depth: cuint8;
sequence: cuint16;
length: cuint32;
root: cuint32;
x: cint16;
y: cint16;
width: cuint16;
height: cuint16;
border_width: cuint16;
pad0: array[0..1] of cuint8;
end;
const
XCB_NONE = 0;
XCB_COPY_FROM_PARENT = 0;
XCB_CURRENT_TIME = 0;
XCB_NO_SYMBOL = 0;
// Connection errors
XCB_CONN_ERROR = 1;
XCB_CONN_CLOSED_EXT_NOTSUPPORTED = 2;
XCB_CONN_CLOSED_MEM_INSUFFICIENT = 3;
XCB_CONN_CLOSED_REQ_LEN_EXCEED = 4;
XCB_CONN_CLOSED_PARSE_ERR = 5;
XCB_CONN_CLOSED_INVALID_SCREEN = 6;
XCB_CONN_CLOSED_FDPASSING_FAILED = 7;
// Event types
XCB_EXPOSE = 12;
XCB_BUTTON_PRESS = 4;
XCB_BUTTON_RELEASE = 5;
XCB_MOTION_NOTIFY = 6;
XCB_ENTER_NOTIFY = 7;
XCB_LEAVE_NOTIFY = 8;
XCB_KEY_PRESS = 2;
XCB_KEY_RELEASE = 3;
// Window creation masks
XCB_CW_BACK_PIXEL = 1 shl 0;
XCB_CW_BORDER_PIXEL = 1 shl 1;
XCB_CW_BIT_GRAVITY = 1 shl 2;
XCB_CW_WIN_GRAVITY = 1 shl 3;
XCB_CW_BACKING_STORE = 1 shl 4;
XCB_CW_BACKING_PLANES = 1 shl 5;
XCB_CW_BACKING_PIXEL = 1 shl 6;
XCB_CW_OVERRIDE_REDIRECT = 1 shl 7;
XCB_CW_SAVE_UNDER = 1 shl 8;
XCB_CW_EVENT_MASK = 1 shl 9;
XCB_CW_DONT_PROPAGATE = 1 shl 10;
XCB_CW_COLORMAP = 1 shl 11;
XCB_CW_CURSOR = 1 shl 12;
// Core connection functions
function xcb_connect(displayname: PChar; screenp: Pcint): Pxcb_connection_t; cdecl; external libxcb;
function xcb_connect_to_fd(fd: cint; auth_info: Pxcb_auth_info_t): Pxcb_connection_t; cdecl; external libxcb;
procedure xcb_disconnect(c: Pxcb_connection_t); cdecl; external libxcb;
function xcb_connection_has_error(c: Pxcb_connection_t): cint; cdecl; external libxcb;
// Setup and file descriptor
function xcb_get_setup(c: Pxcb_connection_t): Pxcb_setup_t; cdecl; external libxcb;
function xcb_get_file_descriptor(c: Pxcb_connection_t): cint; cdecl; external libxcb;
// Event handling
function xcb_wait_for_event(c: Pxcb_connection_t): Pxcb_generic_event_t; cdecl; external libxcb;
function xcb_poll_for_event(c: Pxcb_connection_t): Pxcb_generic_event_t; cdecl; external libxcb;
function xcb_poll_for_queued_event(c: Pxcb_connection_t): Pxcb_generic_event_t; cdecl; external libxcb;
// Special events
function xcb_poll_for_special_event(c: Pxcb_connection_t; se: Pxcb_special_event_t): Pxcb_generic_event_t; cdecl; external libxcb;
function xcb_wait_for_special_event(c: Pxcb_connection_t; se: Pxcb_special_event_t): Pxcb_generic_event_t; cdecl; external libxcb;
function xcb_register_for_special_xge(c: Pxcb_connection_t; ext: Pxcb_extension_t; eid: uint32_t; stamp: Puint32_t): Pxcb_special_event_t; cdecl; external libxcb;
procedure xcb_unregister_for_special_event(c: Pxcb_connection_t; se: Pxcb_special_event_t); cdecl; external libxcb;
// Request handling
function xcb_request_check(c: Pxcb_connection_t; cookie: xcb_void_cookie_t): Pxcb_generic_error_t; cdecl; external libxcb;
procedure xcb_discard_reply(c: Pxcb_connection_t; sequence: cuint); cdecl; external libxcb;
procedure xcb_discard_reply64(c: Pxcb_connection_t; sequence: uint64_t); cdecl; external libxcb;
// Extension handling
function xcb_get_extension_data(c: Pxcb_connection_t; ext: Pxcb_extension_t): Pointer; cdecl; external libxcb;
procedure xcb_prefetch_extension_data(c: Pxcb_connection_t; ext: Pxcb_extension_t); cdecl; external libxcb;
// I/O operations
function xcb_flush(c: Pxcb_connection_t): cint; cdecl; external libxcb;
function xcb_get_maximum_request_length(c: Pxcb_connection_t): uint32_t; cdecl; external libxcb;
procedure xcb_prefetch_maximum_request_length(c: Pxcb_connection_t); cdecl; external libxcb;
// XID generation
function xcb_generate_id(c: Pxcb_connection_t): uint32_t; cdecl; external libxcb;
// Utility functions
function xcb_parse_display(name: PChar; host: PPChar; display: Pcint; screen: Pcint): cint; cdecl; external libxcb;
// Reply functions
function xcb_wait_for_reply(c: Pxcb_connection_t; request: cuint; e: PPxcb_generic_error_t): Pointer; cdecl; external libxcb;
function xcb_wait_for_reply64(c: Pxcb_connection_t; request: uint64_t; e: PPxcb_generic_error_t): Pointer; cdecl; external libxcb;
function xcb_poll_for_reply(c: Pxcb_connection_t; request: cuint; reply: PPointer; error: PPxcb_generic_error_t): cint; cdecl; external libxcb;
function xcb_poll_for_reply64(c: Pxcb_connection_t; request: uint64_t; reply: PPointer; error: PPxcb_generic_error_t): cint; cdecl; external libxcb;
// Statistics
function xcb_total_read(c: Pxcb_connection_t): uint64_t; cdecl; external libxcb;
function xcb_total_written(c: Pxcb_connection_t): uint64_t; cdecl; external libxcb;
procedure cfree(event: Pointer); cdecl; external 'c' name 'free'; // Use standard C free
// GEOMETRY FUNCTIONS
function xcb_get_geometry(conn: Pxcb_connection_t; drawable: cuint32): xcb_get_geometry_cookie_t; cdecl; external libxcb;
function xcb_get_geometry_reply(conn: Pxcb_connection_t; cookie: xcb_get_geometry_cookie_t; error: PPxcb_generic_error_t): Pxcb_get_geometry_reply_t; cdecl; external libxcb;
implementation
end.
unit xcb_events_bindings;
{$mode objfpc}{$H+}
{$PACKRECORDS C}
interface
uses
xcb_bindings, xproto_bindings;
type
// Additional types
xcb_timestamp_t = uint32_t;
// Event structures
Pxcb_expose_event_t = ^xcb_expose_event_t;
xcb_expose_event_t = record
response_type: uint8_t;
pad0: uint8_t;
sequence: uint16_t;
window: xcb_window_t;
x: uint16_t;
y: uint16_t;
width: uint16_t;
height: uint16_t;
count: uint16_t;
pad1: array[0..1] of uint8_t;
end;
Pxcb_button_press_event_t = ^xcb_button_press_event_t;
xcb_button_press_event_t = record
response_type: uint8_t;
detail: uint8_t;
sequence: uint16_t;
time: xcb_timestamp_t;
root: xcb_window_t;
event: xcb_window_t;
child: xcb_window_t;
root_x: int16_t;
root_y: int16_t;
event_x: int16_t;
event_y: int16_t;
state: uint16_t;
same_screen: uint8_t;
pad0: uint8_t;
end;
Pxcb_button_release_event_t = ^xcb_button_release_event_t;
xcb_button_release_event_t = xcb_button_press_event_t;
Pxcb_motion_notify_event_t = ^xcb_motion_notify_event_t;
xcb_motion_notify_event_t = record
response_type: uint8_t;
detail: uint8_t;
sequence: uint16_t;
time: xcb_timestamp_t;
root: xcb_window_t;
event: xcb_window_t;
child: xcb_window_t;
root_x: int16_t;
root_y: int16_t;
event_x: int16_t;
event_y: int16_t;
state: uint16_t;
same_screen: uint8_t;
pad0: uint8_t;
end;
Pxcb_enter_notify_event_t = ^xcb_enter_notify_event_t;
xcb_enter_notify_event_t = record
response_type: uint8_t;
detail: uint8_t;
sequence: uint16_t;
time: xcb_timestamp_t;
root: xcb_window_t;
event: xcb_window_t;
child: xcb_window_t;
root_x: int16_t;
root_y: int16_t;
event_x: int16_t;
event_y: int16_t;
state: uint16_t;
mode: uint8_t;
same_screen_focus: uint8_t;
end;
Pxcb_leave_notify_event_t = ^xcb_leave_notify_event_t;
xcb_leave_notify_event_t = xcb_enter_notify_event_t;
Pxcb_key_press_event_t = ^xcb_key_press_event_t;
xcb_key_press_event_t = record
response_type: uint8_t;
detail: uint8_t;
sequence: uint16_t;
time: xcb_timestamp_t;
root: xcb_window_t;
event: xcb_window_t;
child: xcb_window_t;
root_x: int16_t;
root_y: int16_t;
event_x: int16_t;
event_y: int16_t;
state: uint16_t;
same_screen: uint8_t;
pad0: uint8_t;
end;
Pxcb_key_release_event_t = ^xcb_key_release_event_t;
xcb_key_release_event_t = xcb_key_press_event_t;
const
// Mouse button details
XCB_BUTTON_INDEX_1 = 1;
XCB_BUTTON_INDEX_2 = 2;
XCB_BUTTON_INDEX_3 = 3;
XCB_BUTTON_INDEX_4 = 4;
XCB_BUTTON_INDEX_5 = 5;
// Modifier masks
XCB_MOD_MASK_SHIFT = 1 shl 0;
XCB_MOD_MASK_LOCK = 1 shl 1;
XCB_MOD_MASK_CONTROL = 1 shl 2;
XCB_MOD_MASK_1 = 1 shl 3;
XCB_MOD_MASK_2 = 1 shl 4;
XCB_MOD_MASK_3 = 1 shl 5;
XCB_MOD_MASK_4 = 1 shl 6;
XCB_MOD_MASK_5 = 1 shl 7;
// Button masks
XCB_BUTTON_MASK_1 = 1 shl 8;
XCB_BUTTON_MASK_2 = 1 shl 9;
XCB_BUTTON_MASK_3 = 1 shl 10;
XCB_BUTTON_MASK_4 = 1 shl 11;
XCB_BUTTON_MASK_5 = 1 shl 12;
implementation
end.
unit xcb_ext_bindings;
{$mode objfpc}{$H+}
{$PACKRECORDS C}
interface
uses
ctypes,xcb_bindings;
type
Puint64_t=PQWord;
Puint8_t=PByte;
// Protocol request structure
Pxcb_protocol_request_t = ^xcb_protocol_request_t;
xcb_protocol_request_t = record
count: size_t;
ext: Pxcb_extension_t;
opcode: uint8_t;
isvoid: uint8_t;
end;
// I/O vector structure for send_request functions
Piovec = ^iovec;
iovec = record
iov_base: Pointer;
iov_len: size_t;
end;
const
XCB_REQUEST_CHECKED = 1 shl 0;
XCB_REQUEST_RAW = 1 shl 1;
XCB_REQUEST_DISCARD_REPLY = 1 shl 2;
XCB_REQUEST_REPLY_FDS = 1 shl 3;
// Extended request functions
function xcb_send_request(c: Pxcb_connection_t; flags: cint; vector: Piovec; request: Pxcb_protocol_request_t): cuint; cdecl; external libxcb;
function xcb_send_request64(c: Pxcb_connection_t; flags: cint; vector: Piovec; request: Pxcb_protocol_request_t): uint64_t; cdecl; external libxcb;
function xcb_send_request_with_fds(c: Pxcb_connection_t; flags: cint; vector: Piovec; request: Pxcb_protocol_request_t; num_fds: cuint; fds: Pcint): cuint; cdecl; external libxcb;
function xcb_send_request_with_fds64(c: Pxcb_connection_t; flags: cint; vector: Piovec; request: Pxcb_protocol_request_t; num_fds: cuint; fds: Pcint): uint64_t; cdecl; external libxcb;
// Socket control
function xcb_take_socket(c: Pxcb_connection_t; return_socket: Pointer; closure: Pointer; flags: cint; sent: Puint64_t): cint; cdecl; external libxcb;
function xcb_writev(c: Pxcb_connection_t; vector: Piovec; count: cint; requests: uint64_t): cint; cdecl; external libxcb;
procedure xcb_send_fd(c: Pxcb_connection_t; fd: cint); cdecl; external libxcb;
// File descriptor handling
function xcb_get_reply_fds(c: Pxcb_connection_t; reply: Pointer; replylen: size_t): Pcint; cdecl; external libxcb;
// Utility functions
function xcb_popcount(mask: uint32_t): cint; cdecl; external libxcb;
function xcb_sumof(list: Puint8_t; len: cint): cint; cdecl; external libxcb;
implementation
end.
unit xproto_bindings;
{$mode objfpc}{$H+}
{$PACKRECORDS C}
interface
uses
ctypes,xcb_bindings;
type
int16_t=cint16;
// Basic types from xproto
xcb_window_t = uint32_t;
xcb_colormap_t = uint32_t;
xcb_visualid_t = uint32_t;
// Screen structure
Pxcb_screen_t = ^xcb_screen_t;
xcb_screen_t = record
root: xcb_window_t;
default_colormap: xcb_colormap_t;
white_pixel: uint32_t;
black_pixel: uint32_t;
current_input_masks: uint32_t;
width_in_pixels: uint16_t;
height_in_pixels: uint16_t;
width_in_millimeters: uint16_t;
height_in_millimeters: uint16_t;
min_installed_maps: uint16_t;
max_installed_maps: uint16_t;
root_visual: xcb_visualid_t;
backing_stores: uint8_t;
save_unders: uint8_t;
root_depth: uint8_t;
allowed_depths_len: uint8_t;
end;
// Screen iterator
Pxcb_screen_iterator_t = ^xcb_screen_iterator_t;
xcb_screen_iterator_t = record
data: Pxcb_screen_t;
rem: cint;
index: cint;
end;
const
XCB_WINDOW_CLASS_COPY_FROM_PARENT = 0;
XCB_WINDOW_CLASS_INPUT_OUTPUT = 1;
XCB_WINDOW_CLASS_INPUT_ONLY = 2;
XCB_CW_BACK_PIXMAP = 1 shl 0;
XCB_CW_BACK_PIXEL = 1 shl 1;
XCB_CW_BORDER_PIXMAP = 1 shl 2;
XCB_CW_BORDER_PIXEL = 1 shl 3;
XCB_CW_BIT_GRAVITY = 1 shl 4;
XCB_CW_WIN_GRAVITY = 1 shl 5;
XCB_CW_BACKING_STORE = 1 shl 6;
XCB_CW_BACKING_PLANES = 1 shl 7;
XCB_CW_BACKING_PIXEL = 1 shl 8;
XCB_CW_OVERRIDE_REDIRECT = 1 shl 9;
XCB_CW_SAVE_UNDER = 1 shl 10;
XCB_CW_EVENT_MASK = 1 shl 11;
XCB_CW_DONT_PROPAGATE = 1 shl 12;
XCB_CW_COLORMAP = 1 shl 13;
XCB_CW_CURSOR = 1 shl 14;
// Event masks
XCB_EVENT_MASK_NO_EVENT = 0;
XCB_EVENT_MASK_KEY_PRESS = 1 shl 0;
XCB_EVENT_MASK_KEY_RELEASE = 1 shl 1;
XCB_EVENT_MASK_BUTTON_PRESS = 1 shl 2;
XCB_EVENT_MASK_BUTTON_RELEASE = 1 shl 3;
XCB_EVENT_MASK_ENTER_WINDOW = 1 shl 4;
XCB_EVENT_MASK_LEAVE_WINDOW = 1 shl 5;
XCB_EVENT_MASK_POINTER_MOTION = 1 shl 6;
XCB_EVENT_MASK_POINTER_MOTION_HINT = 1 shl 7;
XCB_EVENT_MASK_BUTTON_1_MOTION = 1 shl 8;
XCB_EVENT_MASK_BUTTON_2_MOTION = 1 shl 9;
XCB_EVENT_MASK_BUTTON_3_MOTION = 1 shl 10;
XCB_EVENT_MASK_BUTTON_4_MOTION = 1 shl 11;
XCB_EVENT_MASK_BUTTON_5_MOTION = 1 shl 12;
XCB_EVENT_MASK_BUTTON_MOTION = 1 shl 13;
XCB_EVENT_MASK_KEYMAP_STATE = 1 shl 14;
XCB_EVENT_MASK_EXPOSURE = 1 shl 15;
XCB_EVENT_MASK_VISIBILITY_CHANGE = 1 shl 16;
XCB_EVENT_MASK_STRUCTURE_NOTIFY = 1 shl 17;
XCB_EVENT_MASK_RESIZE_REDIRECT = 1 shl 18;
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY = 1 shl 19;
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT = 1 shl 20;
XCB_EVENT_MASK_FOCUS_CHANGE = 1 shl 21;
XCB_EVENT_MASK_PROPERTY_CHANGE = 1 shl 22;
XCB_EVENT_MASK_COLOR_MAP_CHANGE = 1 shl 23;
XCB_EVENT_MASK_OWNER_GRAB_BUTTON = 1 shl 24;
// Screen iterator functions
function xcb_setup_roots_iterator(setup: Pxcb_setup_t): xcb_screen_iterator_t; cdecl; external libxcb;
procedure xcb_screen_next(iter: Pxcb_screen_iterator_t); cdecl; external libxcb;
// Window functions
function xcb_create_window(connection: Pxcb_connection_t; depth: uint8_t; window, parent: xcb_window_t;
x, y, width, height: int16_t; border_width, _class: uint16_t; visual: xcb_visualid_t;
value_mask: uint32_t; value_list: Pointer): xcb_void_cookie_t; cdecl; external libxcb;
function xcb_create_window_checked(connection: Pxcb_connection_t; depth: uint8_t; window, parent: xcb_window_t;
x, y, width, height: int16_t; border_width, _class: uint16_t; visual: xcb_visualid_t;
value_mask: uint32_t; value_list: Pointer): xcb_void_cookie_t; cdecl; external libxcb;
function xcb_destroy_window(connection: Pxcb_connection_t; window: xcb_window_t): xcb_void_cookie_t; cdecl; external libxcb;
function xcb_destroy_window_checked(conn: Pxcb_connection_t; window: xcb_window_t): xcb_void_cookie_t; cdecl; external libxcb;
function xcb_map_window(connection: Pxcb_connection_t; window: xcb_window_t): xcb_void_cookie_t; cdecl; external libxcb;
function xcb_map_window_checked(conn: Pxcb_connection_t; window: xcb_window_t): xcb_void_cookie_t; cdecl; external libxcb;
function xcb_unmap_window(conn: Pxcb_connection_t; window: xcb_window_t): xcb_void_cookie_t; cdecl; external libxcb;
function xcb_unmap_window_checked(conn: Pxcb_connection_t; window: xcb_window_t): xcb_void_cookie_t; cdecl; external libxcb;
implementation
end.